package com.dearbinge.data.service.impl.thumbsCommission;

import com.baomidou.mybatisplus.plugins.Page;
import com.dearbinge.data.api.thumbsCommission.ThumbsCommissionService;
import com.dearbinge.data.dao.thumbsCommission.ThumbsCommissionMapper;
import com.dearbinge.data.pojo.thumbsCommission.ThumbsCommission;
import com.dearbinge.data.pojo.thumbsCommission.vo.ThumbsCommissionVO;
import com.dearbinge.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("thumbsCommissionService")
public class ThumbsCommissionServicelmpl implements ThumbsCommissionService {

    @Autowired
    private ThumbsCommissionMapper thumbsCommissionMapper;

    @Override
    public Integer insert(ThumbsCommission thumbsCommission) {

        Integer integer = thumbsCommissionMapper.insert(thumbsCommission);
        return integer;
    }

    @Override
    public Integer delete(Integer id) {
        return thumbsCommissionMapper.delete(id);
    }


    @Override
    public Integer update(ThumbsCommission thumbsCommission) {
        return thumbsCommissionMapper.update(thumbsCommission);
    }

    @Override
    public Page listThumbsCommissionByUserId(String userId, Integer current, Integer size) {
        current = PageUtils.getDefaultValues(current, 1);
        size = PageUtils.getDefaultValues(size, 10);
        Page<ThumbsCommissionVO> page = new Page<ThumbsCommissionVO>(current, size);
        List<ThumbsCommissionVO> list = thumbsCommissionMapper.listThumbsCommissionByUserId(userId, page);
        page.setRecords(list);
        Integer total = thumbsCommissionMapper.countThumbsCommissionByUserId(userId);
        page.setTotal(total);
        return page;
    }
}
